/**
 * Created by hxsd on 2016/7/22.
 */
window.onload=function(){
    var tel=document.getElementById("tel");
    var ysm=document.getElementsByClassName("yzm")[0];
    var user=document.getElementsByClassName("userName")[0];
    tel.oninput=function() {
        var pattern=/^\d{7,11}$/;
        if(pattern.test(tel.value.trim())==false){
            document.getElementById("telBack").innerHTML="必须是7~11位数";
            return false;
        }
        document.getElementById("telBack").innerHTML="";
        return true;
    };
    ysm.onblur=function(){
        var pattern=/\S/;
        if(pattern.test(ysm.value.trim())==false){
            document.getElementById("yzmBack").innerHTML="验证码不能为空";
            return false;
        }
        document.getElementById("yzmBack").innerHTML="";
        return true;
    };
    user.onblur=function(){
        var pattern=/\S/;
        if(pattern.test(user.value.trim())==false){
            document.getElementById("userNameBack").innerHTML="用户名不为空";
            return false;
        }
        document.getElementById("userNameBack").innerHTML="";
        return true;
    };
    tel.onkeydown= function () {
        disable()
    };
    ysm.onkeydown= function () {
        disable()
    };
    user.onkeydown= function () {
        disable()
    };
    function disable(){
        if(tel.onblur()==true&&ysm.onblur()==true&&user.onblur()==true){
            document.getElementById("dl").disabled=false;
        }
    }
};